﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gds.Model.ConfigModel.BasicSystemInfo;
namespace Gds.ViewModel.pageViewModel
{
    public class ServerConfigViewModel : INotifyPropertyChanged
    {
        public static volatile ServerConfigViewModel _instance = null;
        public static object LockHelper = new object();
        public static ServerConfigViewModel Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (LockHelper)
                    {
                        _instance = new ServerConfigViewModel();
                    }
                }
                return _instance;
            }
        }
        #region public Param

        #endregion
        #region Funtion 
        public void Init()
        {
            LoadLocalConfig();
        }
        #region 配置 增删查改
        public void LoadLocalConfig()
        {
            LocalConfig = Utility.Helper.XmlHelper.DeserializeModel<LocalSystemConfig>(Utility.Const.GbUnit.systemFile);
            if (LocalConfig == null) LocalConfig = new LocalSystemConfig();
        }
        public void SaveLocalConfig()
        {
            Utility.Helper.XmlHelper.SerialzeModel<LocalSystemConfig>(LocalConfig, Utility.Const.GbUnit.systemFile);
        }
        #endregion

        #endregion
        #region BasicParam
        private bool _isMainServer;
        private bool _autoStartRunTask;
        private LocalSystemConfig _localConfig;

        public LocalSystemConfig LocalConfig
        {
            get { return _localConfig; }
            set
            {
                _localConfig = value;
                OnPropertyChange("LocalConfig");
            }
        }
        #endregion
        public event PropertyChangedEventHandler PropertyChanged;
        public virtual void OnPropertyChange(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
